package com.ymttest.database.mongo;

import java.util.ArrayList;

import com.mongodb.MongoClientURI;
import com.ymt.core.tool.FormatUtil;
import com.ymt.database.MongoDBDriver;
import com.ymttest.utils.EnvSetup;

public class ChannelConfigWapper {
	MongoDBDriver mdd;

	public ChannelConfigWapper() throws Exception {
		mdd = new MongoDBDriver(new MongoClientURI(EnvSetup.getSystemUrl("set5smsmongourl")));
		mdd.selectCollection("ChannelConfig");
	}

	/**
	 * 用id查询整条记录
	 * 
	 * @param appid
	 * @return ChannelConfigBean
	 * @throws Exception
	 */
	public ChannelConfigBean getCollectionById(String id) throws Exception {
		String re = null;
		ChannelConfigBean bean = null;
		ArrayList<String> list = mdd.selectPartLimit("{\"_id\":\"" + id + "\"}", 1);
		try {
			if (list.size() > 0) {
				re = list.get(0);
				bean = (ChannelConfigBean) FormatUtil.GSONToObject(re, ChannelConfigBean.class);
				return bean;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
